import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { existsSync, mkdirSync } from 'fs';

import { UserService } from './user.service';
import { UserController } from './user.controller';
import { CUserEntity } from './entities/user.entity';
import { CUserHistoryEntity } from './entities/user-history.entity';

// 确保上传目录存在
const uploadDir = './uploads/temp';
if (!existsSync(uploadDir)) {
  mkdirSync(uploadDir, { recursive: true });
}

@Module({
  imports: [
    TypeOrmModule.forFeature([CUserEntity, CUserHistoryEntity]),
  ],
  controllers: [UserController],
  providers: [UserService],
  exports: [UserService],
})
export class UserModule {}
